/////////////////////////////////////////////////////////////////////////////
/*/	
 *	Creator:		Joshua C. Rouzer
 *	Title:			
 *	Last Edited:	06/11/2013
 *	Summary:		
/*/
/////////////////////////////////////////////////////////////////////////////
#include "AnchorPointAnimation.h"
#include "AnimInfo.h"

#include "../source/CSGD_TextureManager.h"
#include "../source/CSGD_Direct3D.h"
//#include "../source/CSGD_DirectInput.h"
//#include "../source/CSGD_XAudio2.h"

#include "AnimInfo.h"

/////////////////////////////////////////////////////////////////////////////
// Function		: 
// Notes		: 
/////////////////////////////////////////////////////////////////////////////
CAnchorPointAnimation::CAnchorPointAnimation()
{
	m_nImageID = -1;

	Name.clear();

	Frames.clear();

	m_fTimeWaited = 0.0f;

	m_pD3D = nullptr;
	//m_pDI = nullptr;
	m_pTM = nullptr;
	//m_pXA = nullptr;
}
/////////////////////////////////////////////////////////////////////////////
// Function		: 
// Notes		: 
/////////////////////////////////////////////////////////////////////////////
CAnchorPointAnimation::~CAnchorPointAnimation()
{
	Shutdown();
}
/////////////////////////////////////////////////////////////////////////////
// Function		: 
// Notes		: 
/////////////////////////////////////////////////////////////////////////////
void CAnchorPointAnimation::Initialize(int ImageID, std::string name, bool loop)
{
	SetImageID(ImageID);
	SetName(name);
	SetIsLoop(loop);

	m_fTimeWaited = 0.0f;

	m_pD3D = CSGD_Direct3D::GetInstance();
	//m_pDI = CSGD_DirectInput::GetInstance();
	m_pTM = CSGD_TextureManager::GetInstance();
	//m_pXA = CSGD_XAudio2::GetInstance();
}
/////////////////////////////////////////////////////////////////////////////
// Function		: 
// Notes		: 
/////////////////////////////////////////////////////////////////////////////
void CAnchorPointAnimation::Shutdown()
{
	Name.clear();

	for(unsigned int j = 0; j < Frames.size(); j++)
	{
		delete Frames[j];
	}
	Frames.clear();

	m_fTimeWaited = 0.0f;


	m_pD3D = nullptr;
	//m_pDI = nullptr;
	m_pTM = nullptr;
	//m_pXA = nullptr;
}
/////////////////////////////////////////////////////////////////////////////
// Function		: 
// Parameters	: bLoop - 
//					fSpeed - 
// Notes		: 
/////////////////////////////////////////////////////////////////////////////
void CAnchorPointAnimation::Play(bool flip, bool bLoop,CAnimInfo& Info)
{
	m_fTimeWaited = 0.0f;
	Info.SetCurrFrame(0);
	Info.SetIsOver(false);
	Info.SetIsPlaying(true);
	Info.SetFlipped(flip);
	Info.SetTimeOnFrame(0.0f);
}

void CAnchorPointAnimation::Pause(CAnimInfo& Info, bool playing)
{
	if(playing == false)
	{
		Info.SetIsPlaying(false);
	}
	else
	{
		Info.SetIsPlaying(true);
		m_fTimeWaited = 0.0f;
	}
}
/////////////////////////////////////////////////////////////////////////////
// Function		: 
// Return		: 
// Notes		: 
/////////////////////////////////////////////////////////////////////////////

void CAnchorPointAnimation::AddFrame(Frame* newFrame) { Frames.push_back(newFrame); }

void CAnchorPointAnimation::SetImageID(int ID) { m_nImageID = ID; }

int CAnchorPointAnimation::GetImageID()
{
	return m_nImageID;
}

void CAnchorPointAnimation::SetName(std::string nem) { Name = nem; }

std::string CAnchorPointAnimation::GetName() { return Name; }

void CAnchorPointAnimation::SetIsLoop(bool Loop) { isLooping = Loop; }
bool CAnchorPointAnimation::GetIsLoop() { return isLooping; }

std::vector<Frame*> CAnchorPointAnimation::GetFrames() { return Frames; }

//CAnchorPointAnimation& CAnchorPointAnimation::operator=(const CAnchorPointAnimation& Other)
//{
//	if(this != Other)
//	{
//		CAnchorPointAnimation* newOne = new CAnchorPointAnimation();
//
//		for(unsigned int i = 0; i < 
//
//		this->SetImageID(Other.GetImageID());
//		this->SetName(*Other.GetName());
//		this->SetIsLoop(*Other.GetIsLoop());
//
//		this->m_fTimeWaited = Other.m_fTimeWaited;
//
//		return *newOne;
//	}
//	else
//		return *this;
//}